/**
 * Carefree Theme - Layout Styles
 * Header, Footer, Navigation and overall layout structure
 */

/* ========== Background Decoration ========== */
.bg-mesh {
    background-image: var(--gradient-mesh);
    background-attachment: fixed;
}

.bg-gradient-subtle {
    background: linear-gradient(180deg, var(--color-bg) 0%, var(--color-bg-alt) 100%);
}

/* ========== Site Header ========== */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: var(--z-fixed);
    transition: all var(--duration-normal) var(--easing);
}

.site-header .header-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-xl);
}

/* Header States */
.site-header.transparent {
    background: transparent;
}

.site-header.scrolled {
    background: var(--glass-bg-light);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--glass-border);
    box-shadow: var(--shadow-md);
}

/* Logo */
.site-logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    text-decoration: none;
    flex-shrink: 0;
}

.site-logo img {
    height: 40px;
    width: auto;
}

.site-logo h1 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin: 0;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Main Navigation */
.main-nav {
    flex: 1;
    display: flex;
    justify-content: center;
}

.nav-list {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-list > li {
    position: relative;
}

.nav-list > li > a {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    border-radius: var(--radius-lg);
    transition: all var(--duration-fast) var(--easing);
}

.nav-list > li > a:hover,
.nav-list > li.active > a {
    color: var(--color-primary);
    background: rgba(99, 102, 241, 0.08);
}

/* Nav Link Underline Effect */
.nav-list > li > a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width var(--duration-fast) var(--easing);
}

.nav-list > li > a:hover::after,
.nav-list > li.active > a::after {
    width: 24px;
}

/* Dropdown Menu */
.nav-list .has-dropdown {
    position: relative;
}

.nav-list .dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    min-width: 200px;
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border-light);
    padding: var(--spacing-sm);
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-fast) var(--easing);
    list-style: none;
    z-index: var(--z-dropdown);
}

.nav-list .has-dropdown:hover .dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.nav-list .dropdown li a {
    display: block;
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    border-radius: var(--radius-md);
    transition: all var(--duration-fast) var(--easing);
}

.nav-list .dropdown li a:hover {
    color: var(--color-primary);
    background: var(--color-bg-alt);
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-shrink: 0;
}

/* Header Search */
.header-search {
    position: relative;
}

.header-search .search-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--color-text-secondary);
    background: var(--color-bg-alt);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--duration-fast) var(--easing);
}

.header-search .search-trigger:hover {
    color: var(--color-primary);
    background: rgba(99, 102, 241, 0.1);
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--color-text-secondary);
    background: var(--color-bg-alt);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--duration-fast) var(--easing);
}

.theme-toggle:hover {
    color: var(--color-accent);
    background: rgba(245, 158, 11, 0.1);
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--color-text);
    background: transparent;
    border: none;
    cursor: pointer;
}

.mobile-menu-toggle .hamburger {
    width: 20px;
    height: 14px;
    position: relative;
}

.mobile-menu-toggle .hamburger span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background: currentColor;
    border-radius: var(--radius-full);
    transition: all var(--duration-fast) var(--easing);
}

.mobile-menu-toggle .hamburger span:nth-child(1) { top: 0; }
.mobile-menu-toggle .hamburger span:nth-child(2) { top: 6px; }
.mobile-menu-toggle .hamburger span:nth-child(3) { top: 12px; }

.mobile-menu-toggle.active .hamburger span:nth-child(1) {
    top: 6px;
    transform: rotate(45deg);
}

.mobile-menu-toggle.active .hamburger span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger span:nth-child(3) {
    top: 6px;
    transform: rotate(-45deg);
}

/* ========== Site Main ========== */
.site-main {
    padding-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

/* Content Layout */
.content-layout {
    display: grid;
    grid-template-columns: 1fr var(--sidebar-width);
    gap: var(--spacing-2xl);
    padding: var(--spacing-3xl) 0;
}

.content-layout.no-sidebar {
    grid-template-columns: 1fr;
}

.main-content {
    min-width: 0;
}

/* ========== Sidebar ========== */
.sidebar {
    position: sticky;
    top: calc(var(--header-height) + var(--spacing-lg));
    height: fit-content;
}

.sidebar .widget:last-child {
    margin-bottom: 0;
}

/* Widget - Author Card */
.widget-author {
    text-align: center;
}

.widget-author .author-avatar {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    margin: 0 auto var(--spacing-md);
    border: 3px solid var(--color-primary);
    padding: 3px;
}

.widget-author .author-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.widget-author .author-name {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.widget-author .author-bio {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-md);
}

.widget-author .author-stats {
    display: flex;
    justify-content: center;
    gap: var(--spacing-xl);
}

.widget-author .stat-item {
    text-align: center;
}

.widget-author .stat-value {
    display: block;
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-text);
}

.widget-author .stat-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* Widget - Hot Articles */
.hot-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.hot-item {
    display: flex;
    gap: var(--spacing-md);
    align-items: flex-start;
}

.hot-rank {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: 600;
    background: var(--color-bg-alt);
    color: var(--color-text-muted);
    border-radius: var(--radius-md);
}

.hot-rank.top {
    background: var(--gradient-primary);
    color: white;
}

.hot-content {
    flex: 1;
    min-width: 0;
}

.hot-title {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: var(--spacing-xs);
    transition: color var(--duration-fast) var(--easing);
}

.hot-title:hover {
    color: var(--color-primary);
}

.hot-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* Widget - Categories */
.category-list {
    list-style: none;
}

.category-list li {
    border-bottom: 1px solid var(--color-border-light);
}

.category-list li:last-child {
    border-bottom: none;
}

.category-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    transition: all var(--duration-fast) var(--easing);
}

.category-list a:hover {
    color: var(--color-primary);
    padding-left: var(--spacing-sm);
}

.category-list .count {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    background: var(--color-bg-alt);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

/* Widget - Tag Cloud */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

/* Widget - Newsletter */
.widget-newsletter .newsletter-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-md);
}

.widget-newsletter .newsletter-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.widget-newsletter .input {
    width: 100%;
}

/* ========== Site Footer ========== */
.site-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border-light);
    margin-top: var(--spacing-4xl);
}

.footer-main {
    padding: var(--spacing-4xl) 0;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr repeat(3, 1fr);
    gap: var(--spacing-3xl);
}

.footer-brand .site-logo {
    margin-bottom: var(--spacing-md);
}

.footer-brand .footer-description {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-lg);
    max-width: 300px;
}

.footer-social {
    display: flex;
    gap: var(--spacing-sm);
}

.footer-social a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--color-bg-alt);
    color: var(--color-text-secondary);
    border-radius: var(--radius-full);
    transition: all var(--duration-fast) var(--easing);
}

.footer-social a:hover {
    background: var(--gradient-primary);
    color: white;
    transform: translateY(-3px);
}

.footer-column h4 {
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-lg);
    color: var(--color-text);
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: var(--spacing-sm);
}

.footer-links a {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    transition: all var(--duration-fast) var(--easing);
}

.footer-links a:hover {
    color: var(--color-primary);
    padding-left: var(--spacing-sm);
}

.footer-bottom {
    padding: var(--spacing-lg) 0;
    border-top: 1px solid var(--color-border-light);
}

.footer-bottom-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.footer-bottom a {
    color: var(--color-text-muted);
}

.footer-bottom a:hover {
    color: var(--color-primary);
}

/* ========== Back to Top Button ========== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all var(--duration-normal) var(--easing);
    box-shadow: var(--shadow-glow);
    z-index: var(--z-fixed);
}

.back-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ========== Search Modal ========== */
.search-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-normal) var(--easing);
}

.search-modal.active {
    opacity: 1;
    visibility: visible;
}

.search-modal-content {
    width: 100%;
    max-width: 640px;
    background: var(--color-surface);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    transform: translateY(-20px) scale(0.95);
    transition: transform var(--duration-normal) var(--easing);
}

.search-modal.active .search-modal-content {
    transform: translateY(0) scale(1);
}

.search-modal-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border-light);
}

.search-modal-header .search-icon {
    color: var(--color-text-muted);
}

.search-modal-header input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: var(--font-size-lg);
    color: var(--color-text);
    outline: none;
}

.search-modal-header input::placeholder {
    color: var(--color-text-muted);
}

.search-modal-header .search-close {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    background: var(--color-bg-alt);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
}

.search-modal-body {
    padding: var(--spacing-lg);
    max-height: 400px;
    overflow-y: auto;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    transition: background var(--duration-fast) var(--easing);
}

.search-result-item:hover {
    background: var(--color-bg-alt);
}

.search-result-item .result-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-alt);
    color: var(--color-text-muted);
    border-radius: var(--radius-md);
}

.search-result-item .result-content {
    flex: 1;
}

.search-result-item .result-title {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
}

.search-result-item .result-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* ========== Mobile Responsive ========== */
@media (max-width: 1024px) {
    .content-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .main-nav {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--color-surface);
        flex-direction: column;
        justify-content: flex-start;
        padding: var(--spacing-xl);
        transform: translateX(-100%);
        transition: transform var(--duration-normal) var(--easing);
        z-index: var(--z-modal);
    }

    .main-nav.active {
        transform: translateX(0);
    }

    .nav-list {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .nav-list > li > a {
        padding: var(--spacing-md);
        font-size: var(--font-size-base);
    }

    .nav-list .dropdown {
        position: static;
        transform: none;
        opacity: 1;
        visibility: visible;
        box-shadow: none;
        border: none;
        background: var(--color-bg-alt);
        margin-top: var(--spacing-sm);
        display: none;
    }

    .nav-list .has-dropdown.open .dropdown {
        display: block;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .header-actions .header-search,
    .header-actions .theme-toggle {
        display: none;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .footer-brand .footer-description {
        max-width: none;
    }

    .footer-social {
        justify-content: center;
    }

    .footer-bottom-inner {
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 44px;
        height: 44px;
    }
}
